package acwing._1_1AlgorithmBasic._5DynamicProgramming;
/**
 * @Project : AlgorithmLearning
 * @Package : ACWing._1_1AlgorithmBasic._5DynamicProgramming
 * @File : Q0004.java
 * @Author : WangRuoyu
 * @Date : 2023/4/6 10:09
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Q0009 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] words = br.readLine().split(" ");
        int N = Integer.parseInt(words[0]);
        int V = Integer.parseInt(words[1]);

        int[][] w = new int[N + 1][101];
        int[][] v = new int[N + 1][101];
        int[] s = new int[N + 1];
        int cnt = 0;
        for (int i = 1; i <= N; ++i) {
            words = br.readLine().split(" ");
            s[i] = Integer.parseInt(words[0]);
            for (int j = 1; j <= s[i]; ++j) {
                words = br.readLine().split(" ");
                v[i][j] = Integer.parseInt(words[0]);
                w[i][j] = Integer.parseInt(words[1]);
            }
        }

        int[] f = new int[V + 1];
        for (int i = 1; i <= N; ++i) {
            for (int j = V; j >= 0; --j) {
                for (int k = 1; k <= s[i]; ++k) {
                    if (j >= v[i][k]) {
                        f[j] = Math.max(f[j], f[j - v[i][k]] + w[i][k]);
                    }
                }
            }
        }
        System.out.println(f[V]);
    }
}

